import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Index',
      component: () => import('@/views/index.vue'),
    },
    {
      path: '/monitor/:id?',
      name: 'Monitor',
      component: () => import('@/views/monitor.vue'),
    },
    {
      path: '/error',
      name: 'Error',
      component: () => import('@/views/error.vue'),
    },
  ],
})

// @ts-expect-error
// const env = window.__wxjs_environment

// router.beforeEach((to, from, next) => {
//   if (to.name === 'Error' || env === 'miniprogram') {
//     next()
//   } else {
//     next({ name: 'Error' })
//   }
// })

export default router
